let util = require('util');

// inspect：将对象转为字符串
const obj = {name:'inspect',date:'2022-09-01'}
const str = util.inspect(obj)
console.log('str: ', str);


// types: 判断变量/函数的一些类型
const {isAnyArrayBuffer,isAsyncFunction,isDate} = util.types
// isDate:判断是否是函数
const is_date = isDate(new Date())
const is_date2 = isDate('2022-09-01')
console.log('is_date2: ', is_date2);
console.log('is_date: ', is_date);
// isAnyArrayBuffer:判断是否是buffer
const isBuff1 = isAnyArrayBuffer('buffer')
console.log('isBuff1: ', isBuff1);
const isBuff2 = isAnyArrayBuffer(new ArrayBuffer(14))
console.log('isBuff2: ', isBuff2);
// 函数：isAsyncFunction判断函数是否是异步的
const f2 = async function function2(){} 
const f1 = function function1(){} 
const isAsyncFunc = isAsyncFunction(f1)
const isAsyncFunc2 = isAsyncFunction(f2)
console.log('isAsyncFunc2: ', isAsyncFunc2);
console.log('isAsyncFunc: ', isAsyncFunc);

// 格式化字符串util.format(arg1,arg2,arg3,arg4)
const str2 = util.format('%s:%s','12','34','56')
console.log('str2: ', str2);
// 将函数包装为弃用
util.deprecate(()=>{
    console.log('this is a deprecate func')
})
// isDeepStrictEqual 严格相等判断，相当于 ===
const v1 = '2'
const v2 = 2;
const isEqual = util.isDeepStrictEqual(v1,v2)
console.log('isEqual: ', isEqual);
console.log(v1 == v2);
console.log(v1 === v2);